﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
using System.Web.Configuration;
using System.Data;

public partial class Index : BasePage
{
    Access ac = new Access();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            //DXService.FocusSMSWebServiceSoapClient c = new DXService.FocusSMSWebServiceSoapClient();
            //string userName = "service@crmfocussend.com";
            //string pwd = "123456a";
            //string encodedPwd = FormsAuthentication.HashPasswordForStoringInConfigFile(pwd, FormsAuthPasswordFormat.SHA1.ToString("G"));
            //string taskName = "短信即时发送_" + DateTime.Now.ToString();
            //string mobileList = "13611726066,18621837162,18621550015";
            //string content = @"隐藏在闹市深处，鱼龙混杂的市场里，是别有洞天的秘密花园、高贵典雅是我的代名词。欢迎来到上海Venus Spring Massage！隐藏在闹市深处，鱼龙混杂的市场里，是别有洞天的秘密花园、高贵典雅是我的代名词。欢迎来到上海Venus Spring Massage！";
            //string priority = "1";
            //string addrial = "1";
            //string msg = c.SendNote(userName, encodedPwd, taskName, mobileList, content, priority, addrial);
            string lblMenu = "";
            DataTable dt = ac.GetNewMenu(CurrentUserInfo.ID.ToString());
            List<string> list = new List<string>();
            DataRow [] rows= dt.Select("parentid=1");
            int i = 0;
            foreach (DataRow dr in rows)
            {
                if (dr["haveC"].ToString() == "haveC")
                {
                    i++;
                    list.Add(dr["ID"].ToString());
                    lblMenu += string.Format("<a href='javascript:void(0)' id='mb{0}' class='easyui-menubutton' menu='#mm{0}' {1}>{2}</a>&nbsp;&nbsp;", i, "", dr["MenuName"].ToString());
                }
                else
                {
                    lblMenu += string.Format("<a href=\"javascript:AddTab('{2}','{0}','{1}')\" style='text-decoration:none;'   iconcls='{1}'>{2}</a>&nbsp;&nbsp;", dr["MenuUrl"].ToString(), dr["MenuIcon"].ToString(), dr["MenuName"].ToString());
                }
            }
            i = 0;
            foreach (string id in list)
            {
                i++;
                rows = dt.Select("parentid="+id);
                lblMenu2.Text += "<div id='mm"+i+"' style='width: 150px;'>";
                foreach (DataRow dr in rows)
                {
                    if (dr["haveC"].ToString() == "haveC")
                    {
                        DataRow [] rows2 = dt.Select("parentid=" + dr["ID"].ToString());
                        lblMenu2.Text += " <div><span>" + dr["MenuName"].ToString() + "</span><div style='width: 150px;'>";
                        foreach (DataRow d in rows2)
                        {
                            lblMenu2.Text += string.Format("<div iconcls='{0}' onclick=\"AddTab('{1}','{2}','{0}')\">{1}</div>", d["MenuIcon"].ToString(), d["MenuName"].ToString(), d["MenuUrl"].ToString());
                        }
                        lblMenu2.Text += " </div> </div>";
                    }
                    else
                    {
                        lblMenu2.Text += string.Format("<div iconcls='{0}' onclick=\"AddTab('{1}','{2}','{0}')\">{1}</div>", dr["MenuIcon"].ToString(), dr["MenuName"].ToString(), dr["MenuUrl"].ToString());
                    }
                }
                lblMenu2.Text += " </div>";
            }

            div1.InnerHtml = lblMenu;
            
        }
    }

    //protected void btnSendMsg_Click(object sender, EventArgs e)
    //{
    //    DXService. mFocusSMS = new DXService();

    //    string userName = "ljt@focussend.com";
    //    string pwd = "4545645";
    //    string encodedPwd = FormsAuthentication.HashPasswordForStoringInConfigFile(pwd, FormsAuthPasswordFormat.SHA1.ToString("G"));
    //    string taskName = "短信即时发送_" + DateTime.Now.ToString();
    //    string mobileList = "15921950317";
    //    string content = "Focus短信测试";
    //    string priority = "1";
    //    string addrial = "1";
    //    string msg = mFocusSMS.SendNote(userName, encodedPwd, taskName, mobileList, content, priority, addrial);
    //}



    //protected void btnTimingSendMsg_Click(object sender, EventArgs e)
    //{
    //     FocusSMSWebService mFocusSMS = new FocusSMSWebService();

    //    string userName = "ljt@focussend.com";
    //    string pwd = "4545645";
    //    string encodedPwd = FormsAuthentication.HashPasswordForStoringInConfigFile(pwd, FormsAuthPasswordFormat.SHA1.ToString("G"));
    //    string taskName = "短信即时发送_" + DateTime.Now.ToString();
    //    string mobileList = "15921950317";
    //    string content = "Focus短信定时测试";
    //    string priority = "1";
    //    string addrial = "1";
    //    string schTime = "20130704153041";
    //    string msg = mFocusSMS.TimingSendNot(userName, encodedPwd, taskName, mobileList, content, priority, addrial, schTime);
    //}


    //protected void btnGetBalance_Click(object sender, EventArgs e)
    //{
    //    FocusSMSWebService mFocusSMS = new FocusSMSWebService();
    //    string userName = "ljt@focussend.com";
    //    string pwd = "4545645";
    //    string encodedPwd = FormsAuthentication.HashPasswordForStoringInConfigFile(pwd, FormsAuthPasswordFormat.SHA1.ToString("G"));
    //    string msg = mFocusSMS.GetBalance(userName, encodedPwd);
    //    Response.Write(msg);
    //}

    public string Title
    {
        get
        {
            string re = "[" + CurrentUserInfo.UserName + "]，欢迎您！" + Request.UserHostAddress.ToString();
            return re;
        }
    }
}